import React from 'react'
import {ListProps} from '../shoppmodel/Shoppingcar'
interface Istate{
  list:Array<ListProps>
  calc:(id:number,num:number)=>void
  setCheckOne:(id:number,num:boolean)=>void
  delid:(id:number)=>void
}
export default function Content({list,calc,setCheckOne,delid}:Istate) {
  return (
    <>
    {list.map(item=>
      <div className='tr' key={item.id}>
        <div className="td" >
      <div className="checkall">
      <input
            type="checkbox"
            checked={item.checked}
            onChange={(e)=>{
              setCheckOne(item.id,e.target.checked)
            }}
          />
      </div>
          <div>{item.name}</div>
          <div>{item.price}</div>
          <div>
             {item.num>1?<button onClick={()=>{
                calc(item.id,-1)
              }}>-</button>:<button>-</button>}
              <input  type='text'value={item.num} onChange={()=>{}}/>
              <button className="add" onClick={()=>{
                calc(item.id,1)
              }}>+</button>
          </div>
          <div>{(item.num*item.price).toFixed(2)}</div>
          <div onClick={()=>{delid(item.id)}}>删除</div>
  </div>
      </div>
      )}
            
    </>
  )
}
